examples/fixed/*, examples/frame/* - Examples from the Tutorial
authorGMT 1999 Tony Gake <gale@gtk.org>
Fri, 29 Jan 1999 09:53:14 +0000 (09:53 +0000)
committerTony Gale <gale@src.gnome.org>
Fri, 29 Jan 1999 09:53:14 +0000 (09:53 +0000)
Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>

        * examples/fixed/*, examples/frame/*
          - Examples from the Tutorial

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
examples/fixed/Makefile [new file with mode: 0644]
examples/fixed/fixed.c [new file with mode: 0644]
examples/frame/Makefile [new file with mode: 0644]
examples/frame/frame.c [new file with mode: 0644]

index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
index 091e23d8f7c952e9035c0484ba27556aacafa9c0..55ff7712c70d5a44780282c47cfddc20675f7199 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan 29 09:44:37 GMT 1999 Tony Gake  <gale@gtk.org>
+
+       * examples/fixed/*, examples/frame/*
+         - Examples from the Tutorial
+
 Fri Jan 29 09:18:41 GMT 1999 Tony Gale  <gale@gtk.org>
 
        * docs/gtk_tut.sgml:
diff --git a/examples/fixed/Makefile b/examples/fixed/Makefile
new file mode 100644 (file)
index 0000000..c7fc247
--- /dev/null
@@ -0,0 +1,8 @@
+
+CC = gcc
+
+fixed: fixed.c 
+       $(CC) `gtk-config --cflags`  fixed.c -o fixed `gtk-config --libs`
+
+clean: 
+       rm -f *.o fixed
diff --git a/examples/fixed/fixed.c b/examples/fixed/fixed.c
new file mode 100644 (file)
index 0000000..372b1ad
--- /dev/null
@@ -0,0 +1,74 @@
+/* example-start fixed fixed.c */
+
+#include <gtk/gtk.h>
+
+/* I'm going to be lazy and use some global variables to
+ * store the position of the widget within the fixed
+ * container */
+gint x=50;
+gint y=50;
+
+/* This callback function moves the button to a new position
+ * in the Fixed container. */
+void move_button( GtkWidget *widget,
+                  GtkWidget *fixed )
+{
+  x = (x+30)%300;
+  y = (y+50)%300;
+  gtk_fixed_move( GTK_FIXED(fixed), widget, x, y); 
+}
+
+int main( int   argc,
+          char *argv[] )
+{
+  /* GtkWidget is the storage type for widgets */
+  GtkWidget *window;
+  GtkWidget *fixed;
+  GtkWidget *button;
+  gint i;
+
+  /* Initialise GTK */
+  gtk_init(&argc, &argv);
+    
+  /* Create a new window */
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(window), "Fixed Container");
+
+  /* Here we connect the "destroy" event to a signal handler */ 
+  gtk_signal_connect (GTK_OBJECT (window), "destroy",
+                     GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+  /* Sets the border width of the window. */
+  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+  /* Create a Fixed Container */
+  fixed = gtk_fixed_new();
+  gtk_container_add(GTK_CONTAINER(window), fixed);
+  gtk_widget_show(fixed);
+  
+  for (i = 1 ; i <= 3 ; i++) {
+    /* Creates a new button with the label "Press me" */
+    button = gtk_button_new_with_label ("Press me");
+  
+    /* When the button receives the "clicked" signal, it will call the
+     * function move_button() passing it the Fixed Containter as its
+     * argument. */
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                       GTK_SIGNAL_FUNC (move_button), fixed);
+  
+    /* This packs the button into the fixed containers window. */
+    gtk_fixed_put (GTK_FIXED (fixed), button, i*50, i*50);
+  
+    /* The final step is to display this newly created widget. */
+    gtk_widget_show (button);
+  }
+
+  /* Display the window */
+  gtk_widget_show (window);
+    
+  /* Enter the event loop */
+  gtk_main ();
+    
+  return(0);
+}
+/* example-end */
diff --git a/examples/frame/Makefile b/examples/frame/Makefile
new file mode 100644 (file)
index 0000000..0afdbf2
--- /dev/null
@@ -0,0 +1,8 @@
+
+CC = gcc
+
+frame: frame.c 
+       $(CC) `gtk-config --cflags`  frame.c -o frame `gtk-config --libs`
+
+clean: 
+       rm -f *.o frame
diff --git a/examples/frame/frame.c b/examples/frame/frame.c
new file mode 100644 (file)
index 0000000..6091f01
--- /dev/null
@@ -0,0 +1,52 @@
+/* example-start frame frame.c */
+
+#include <gtk/gtk.h>
+
+int main( int   argc,
+          char *argv[] )
+{
+  /* GtkWidget is the storage type for widgets */
+  GtkWidget *window;
+  GtkWidget *frame;
+  GtkWidget *button;
+  gint i;
+
+  /* Initialise GTK */
+  gtk_init(&argc, &argv);
+    
+  /* Create a new window */
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(window), "Frame Example");
+
+  /* Here we connect the "destroy" event to a signal handler */ 
+  gtk_signal_connect (GTK_OBJECT (window), "destroy",
+                     GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+
+  gtk_widget_set_usize(window, 300, 300);
+  /* Sets the border width of the window. */
+  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+  /* Create a Frame */
+  frame = gtk_frame_new(NULL);
+  gtk_container_add(GTK_CONTAINER(window), frame);
+
+  /* Set the frames label */
+  gtk_frame_set_label( GTK_FRAME(frame), "GTK Frame Widget" );
+
+  /* Align the label at the right of the frame */
+  gtk_frame_set_label_align( GTK_FRAME(frame), 1.0, 0.0);
+
+  /* Set the style of the frame */
+  gtk_frame_set_shadow_type( GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
+
+  gtk_widget_show(frame);
+  
+  /* Display the window */
+  gtk_widget_show (window);
+    
+  /* Enter the event loop */
+  gtk_main ();
+    
+  return(0);
+}
+/* example-end */